import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.Set;

/**
 * @author xiezhicong xiezc@3vjia.com
 * @since 2019-12-02 20:12
 */
public class TestSelect {

    public static Selector selector;

    public static void main(String[] args) throws Exception {
        selector = Selector.open();
    new Thread(()->{
        try{
            System.out.println("子线程睡眠");
            Thread.sleep(10000l);
            System.out.println("子线程叫醒主线程");
            selector.wakeup();
        }catch (Exception e){
            e.printStackTrace();
        }
    }).start();
       int  i = selector.select();
        System.out.println(i);
        Set<SelectionKey> hello = selector.selectedKeys();
        System.out.println(hello);
    }
}
